#include"stack.h"
bool IsVliad(char* s)
{
	ST ps;
	STInit(&ps);
	char topval;

	while (*s)
	{
		switch (*s)
		{
		case '{':
		case '[':
		case '(':
			STPush(&ps,*s);
			break;
		case'}':
		case']':
		case')':
			if (STEmpty(&ps))
			{
				STDestroy(&ps);
				return false;
			}
			topval = STTop(&ps);
			STPop(&ps);
			if (( * s == ']' && topval != '[')
				||( * s == ')' && topval != '(')
				|| ( * s == '}' && topval != '{'
				))
			{
				STDestroy(&ps);
				return false;
			}
			break;



		}
		s++;
		



	}
	bool ret = STEmpty(&ps);
	STDestroy(&ps);
	return ret;



}
int main()
{
	ST st;
	STInit(&st);
	STPush(&st,1);
	STPush(&st,2);
	STPush(&st,3);
	STPush(&st,4);
	while (!STEmpty(&st))
	{
		//printf("%d", STTop(&st));
		STPop(&st);
	}
	printf("\n");


	STDestroy(&st);


	char s[] = { ' [','}','(',')','[','9'};
	printf("%d",IsVliad(s));
	return 0;
}